home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / examples / pwd < prev    next >
Text File  |  1994-09-20  |  687b  |  50 lines

  1. //
  2. // Randomly generate passwordds
  3. // Ian Searle (11/6/91)
  4. //
  5.  
  6. static (alpha)
  7.  
  8. alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", ...
  9.          "j", "k", "l", "m", "n", "o", "p", "q", "r", ...
  10.          "s", "t", "u", "v", "w", "x", "y", "z" ];
  11.  
  12. //
  13. // Global set-up
  14. //
  15.  
  16. srand( "clock" );
  17.  
  18.  
  19. //
  20. // Return an integer random number between 1 and 26
  21. //
  22.  
  23. irand = function()
  24. {
  25.   return int( rand() );
  26. }
  27.  
  28. //
  29. // Generate a password
  30. //
  31.  
  32. pwd = function()
  33. {
  34.   tmp = "";
  35.   rand("uniform", 1, 26);
  36.   for(i in 1:6) 
  37.   {
  38.     PWD[i]   = alpha[ irand() ];
  39.   }
  40.   
  41.   rand("uniform", 0, 9);
  42.   
  43.   sprintf(tmp, "%i", irand());
  44.   PWD[7] = tmp;
  45.   sprintf(tmp, "%i", irand());
  46.   PWD[8] = tmp;
  47.   
  48.   return PWD;
  49. }
  50.